home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group02b.txt
/
000088_icon-group-sender_Thu Oct 24 12:29:15 2002.msg
< prev
next >
Wrap
Internet Message Format
|
2003-01-02
|
4KB
Return-Path: <icon-group-sender>
Received: (from root@localhost)
by baskerville.CS.Arizona.EDU (8.11.1/8.11.1) id g9OJSmU00911
for icon-group-addresses; Thu, 24 Oct 2002 12:28:48 -0700 (MST)
Message-Id: <200210241928.g9OJSmU00911@baskerville.CS.Arizona.EDU>
Date: Thu, 24 Oct 2002 08:46:16 -0700
From: Steve Wampler <swampler@noao.edu>
X-Accept-Language: en
To: Trinity Palakkad <tipl2@hotmail.com>,
icon-group <icon-group@cs.arizona.edu>
Subject: Re: Doubts in programming
Errors-To: icon-group-errors@cs.arizona.edu
Status: RO
Trinity Palakkad wrote:
>
> Program 1
>
> link wopen
>
> procedure main()
> WOpen("size=300,400","pos=100,100")
> WAttrib("bg=blue","fg=white","canvas=hidden")
> WDone()
> end
>
> After executing the program,no other programs can be executed
> due to some linking error.Even the same program cannot be run
> for a second time.What change is to be made to the program?
What linking error? I don't think that's what you're seeing.
I think you're seeing the fact that WDone says to wait for
a 'Q' or 'q' to be typed into the window before processing and
you can't do that because you've opened the window as 'hidden',
so you can't see it to type the 'Q' or 'q'. Try:
procedure main()
WOpen("size=300,400","pos=100,100")
WAttrib("bg=blue","fg=white","canvas=normal")
WDone()
end
instead and then type Q or q inside the window. Or consider
using WClose() instead of WDone, depending on what you want to
do...
> Program 2
>
> link wopen
>
> procedure main()
> WOpen("size=300,400","pos=100,100","label=W1")
> WAttrib("bg=blue","fg=white","canvas=normal")
> WWrite("The window is in the normal state")
> WOpen("size=300,400","pos=200,200","label=W2")
> WAttrib("bg=blue","fg=white","canvas=hidden")
> WDone()
> end
>
> The program does not produce the desired result.
> W2 has to be closed.Instead,W1 is being closed.
> What change is to be made to the program?
Well, it does do what you told it to do, so I guess that
wasn't what you desired...
The first WOpen sets &window, which is then used by subsequent
Wxxx() functions that don't specify a window. So the 2nd
WAttrib() call that sets the canvas to hidden is hiding the
first window, not the second.
I've found it to be good practice to use explicit window
names anytime I'm using more than one window. Doing so,
the above program would be (something like):
link wopen
procedure main()
w1 := WOpen("size=300,400","pos=100,100","label=W1")
WAttrib(w1,"bg=blue","fg=white","canvas=normal")
WWrite(w1,"The window is in the normal state")
w2 := WOpen("size=300,400","pos=200,200","label=W2")
WAttrib(w2,"bg=blue","fg=white","canvas=hidden")
WClose(w2)
WDone(w1)
end
Note that I'm using WClose(w2) and not WDone(w2) - since you've
got w2 'hidden', WDone(w2) would be a problem, just as it was
with the hidden window in your first example.
If you don't have the "Graphics Programming in Icon" book, you
should get it as an invaluable reference.
> _________________________________________________________________
> Choose an Internet access plan right for you -- try MSN!
> http://resourcecenter.msn.com/access/plans/default.asp
--
Steve Wampler -- swampler@noao.edu
Quantum materiae materietur marmota monax si marmota
monax materiam possit materiari?